const BaseRest = require('../rest.js')

module.exports = class extends BaseRest {
  async deleteAction () {
    const id = this.getId()
    await this.modelInstance.where({parent_path: ['LIKE', `%/${id}%`]}).delete()
    await this.modelInstance.where({id: id}).delete()
    this.success()
  }
  async categoryTreeAction () {
    let categoryList = await this.modelInstance.select()
    this.success(this.formatTree(categoryList))
  }
};
